export default app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const MedicalField = app.model.define('MedicalField', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    uuid: { type: STRING(36), unique: true },
    name: STRING(10),
    createdAt: DATE,
    updatedAt: DATE,
  }, {
    tableName: 'medical_field'
  });

  MedicalField.associate = () => {
    app.model.MedicalField.hasMany(app.model.Company, {
      foreignKey: 'medical_field',
      sourceKey: 'uuid',
    });
  };
  return MedicalField;
};
